home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1937 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.4 KB

  1. Path: sabik.tdb.uu.se!m92fra
  2. From: m92fra@sabik.tdb.uu.se (Fredrik Raadesand)
  3. Newsgroups: comp.lang.c++,comp.lang.c
  4. Subject: Re: Performance: C vs. C++
  5. Date: 14 Jan 1996 09:17:20 GMT
  6. Organization: department of Scientific Computing, Uppsala University, Sweden
  7. Message-ID: <4dahn0$lei@columba.udac.uu.se>
  8. NNTP-Posting-Host: sabik.tdb.uu.se
  9.  
  10. In article <30F6BAAC.12B5@iastate.edu> you wrote:
  11. : Hi,
  12.  
  13. : I was wondering if anyone could tell me what the difference in performance would be between 
  14. : writing a program in C++ vs. C.  Assume that the compilers are both of equal quality.  I know 
  15. : that certain features such as virtual functions and exception handling add overhead.  Are there 
  16. : any others?  If you don't implement these features that add the extra overhead, is C++ directly 
  17. : comparable to C in performance then?  The only other reason I could see C++ being slower than C 
  18. : is programming style.  Object-oriented is slower since there are more layers, hence function call 
  19. : overhead.
  20.  
  21. : Anyone with some answers, disagreements?  Thanks.
  22.  
  23. I do not wish to argue about c vs. c++ compilers but I can tell you this...
  24.  
  25. Last night I did a couple of very simple tests...I made two test's as to
  26. compare Linux/GNU C compiler vs. DOS/Borland C++ with respect to
  27. execution speed of looping/integer math and looping/floating point math
  28.   Although my objetive was to compare DOS to Linux and not to
  29.   compare the compilers and the results I guess shows Linux to be superior
  30.   to DOS, but however I thought you c-freaks might be interested anyway :)
  31. )
  32.  
  33. Test 1. A simple integration using simpsons algoritm, uses double types.(float)
  34.                  DOS/BCC             Linux/GCC
  35. Exec.time:       17.6 sec            10.0 sec
  36.  
  37. Test 2. A simple loop just counting up a long int counter.(no float here)
  38.                  DOS/BCC             Linux/GCC
  39. Exec.time:       12.4 sec            6.6 sec
  40.  
  41. So if you are interested in performance ? Trash DOS ! I guess running
  42. DOS on 386-system is like driving a 4-cyl. car with two sparc-plugs ripped
  43. out, it'll run but it sure is a waste of fuel.
  44.  
  45. Or maybe this one is even better...
  46.  Running a 4 cyl. car with two sparc plugs ripped out is like running a
  47.  386-system with 16 bits ripped out, it'll run but it sure looks like DOS
  48.  to me ? :-)
  49.  
  50. : -- 
  51. : Steve Lee
  52. : Computer Engineering/Computer Science
  53. : Iowa State University
  54. : email -> sjlee@iastate.edu
  55. : WWW   -> http://www.cs.iastate.edu/~sjlee/homepage.html
  56.  
  57.  /Fredrik
  58.   m92fra@student.tdb.uu.se
  59.